package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.entity.Room;
import com.example.demo.mapper.RoomMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/room")
public class RoomController {
    @Autowired
    @Resource
    RoomMapper roomMapper;

    @GetMapping("/data")
    public Result<?> getRoom(){
        List<Room> rooms = roomMapper.selectRoomAll();
        return Result.success(rooms);
    }

    @PutMapping("/cleanUp")
    public Result<?> updateState(@RequestParam String roomId){
        roomMapper.updateState0ByRoomId(roomId);
        return Result.success();
    }
}
